/* @flow strict-local */

import * as eg from '../../../__tests__/lib/exampleData';
import header from '../header';
import type { BackgroundData } from '../../backgroundData';
import { makeMuteState } from '../../../mute/__tests__/mute-testlib';
import { mock_ } from '../../../__tests__/lib/intl';

const backgroundData: BackgroundData = ({
  mute: makeMuteState([]),
  ownEmail: eg.selfUser.email,
  subscriptions: [eg.stream],
  streams: new Map([[eg.stream.stream_id, eg.stream]]),
}: $FlowFixMe);

describe('header', () => {
  test('correctly encodes `<` in topic, in stream narrow', () => {
    const m = eg.streamMessage({ subject: '1 < 2' });
    const h = header(
      backgroundData,
      {
        type: 'header',
        key: [m.id, 1],
        style: 'topic+date',
        subsequentMessage: m,
      },
      mock_,
    );
    expect(h).not.toContain('1 < 2');
    expect(h).toContain('1 &lt; 2');
    expect(h).not.toContain('1 &amp;lt; 2');
  });

  // TODO: test other cases, and other pieces of data (stream name, user names, etc.)
});
